import dayjs from 'dayjs'
import storage from 'good-storage'

const ACCESS_TOKEN = '__accessToken__'
const EXPIRES_IN = '__expiresIn__'

export function getToken() {
  return storage.get(ACCESS_TOKEN, '')
}

export function setToken(token) {
  return storage.set(ACCESS_TOKEN, token)
}

export function removeToken() {
  return storage.remove(ACCESS_TOKEN)
}

export function getExpiresIn() {
  return storage.get(EXPIRES_IN, '')
}

export function setExpiresIn(time) {
  const times = dayjs().add(time, 'second').valueOf()
  return storage.set(EXPIRES_IN, times)
}

export function removeExpiresIn() {
  return storage.remove(EXPIRES_IN)
}
